<template>
	<view class="editBox">
		<!-- 头像 -->
		<view class="head_portrait">
			<cover-image class="image" :src="userData.avatarUrl"></cover-image>
		</view>
		<!-- 编辑个人信息 -->
		<view class="editMsg">
			<view class="line">
				<view class="">
					昵称
				</view>
				<view class="">
					<input type="text" v-model="userName" />
				</view>
				<view class="">

				</view>
			</view>
			<view class="line">
				<view class="">
					性别
				</view>
				<view class="">
					<input type="text" v-model="userSex" />
				</view>
				<view class="">

				</view>
			</view>
			<view class="line">
				<view class="">
					生日
				</view>
				<view class="">
					<input type="text" value="生日" />
				</view>
				<view class="">
			
				</view>
			</view>
		</view>
		<view class="editMsg2">
			<uni-list>
			    <uni-list-item title="手机号" rightText="未绑定" link ></uni-list-item>
			    <uni-list-item title="邮箱" rightText="未绑定" link ></uni-list-item>
			</uni-list>
			<view class="save">
				<button class="" type="default" @click="saveMsg">保存</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userData: null,
				userName:'',
				userSex:'男',
			}
		},
		onLoad(option) {
			this.userData = JSON.parse(option.userData)
			console.log(this.userData)
			this.userName =  this.userData.nickName
		},
		methods: {
			// 保存更改信息
			saveMsg(){
				let obj = {
					avatarUrl: this.userData.avatarUrl,
					city: '',
					country: '',
					gender: this.userSex,
					language: '',
					nickName: this.userName,
					province: '',
				}
				uni.setStorage({
					key:"usertoken",
					data:obj,
					success(res){
						uni.reLaunch({
							url:"/pages/my/my"
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	/* 头像 */
	.head_portrait {
		width: 100%;
		height: 150px;
		background: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		margin-bottom: 10px;
	}

	.head_portrait .image {
		width: 70px;
		height: 70px;
		border-radius: 50%;
	}

	.editMsg {
		width: 100%;
		height: auto;
		background: #fff;
		margin-bottom:10px;
	}
	.editMsg .line{
		height:50px;
		width:100%;
		box-shadow: 0px 1px 0px #f0f0f0;
		display:flex;
		align-items: center;
		font-size:13px;
	}
	.editMsg .line:last-child{
		box-shadow: none;
	}
	.editMsg .line view:nth-child(1){
		flex:.2;
		text-align: center;
	}
	.editMsg .line view:nth-child(2){
		flex:.3;
		text-align: left;
		margin-left:20px;
		color:#a2a2a2;
		display:flex;
	}
	.editMsg .line view:nth-child(3){
		flex:.5
	}
	.editMsg2{
		width:100%;
		height:calc(100vh - 150px - 170px);
		background-color: #fff;
		position: relative;
	}
	.save{
		position: absolute;
		left:0;
		bottom:20px;
		padding:20px;
		width:100%;
		box-sizing: border-box;
	}
	.save button{
		width:100%;
		height:44px;
		background:#333;
		color:#fff;
		font-size:13px;
		display:flex;
		align-items: center;
		justify-content: center;
	}
</style>
